/*
 * AlbumTableModel.java
 *
 * Created on June 11, 2005, 1:19 PM
 */
package com.bff.slimserver.musicjukebox.lib;

import com.bff.bjj.utils.Resources.LABEL_KEY;
import org.bff.slimserver.exception.SlimException;
import org.bff.slimserver.musicobjects.SlimGenre;
import org.bff.slimserver.musicobjects.SlimSong;

/**
 *
 * @author Bill
 */
public class GenreTableModel extends SongTableModel {

    public static final int ARTIST = 0;
    public static final int ALBUM = 1;
    public static final int TITLE = 2;
    public static final int LENGTH = 3;
    public static final int TRACK = 4;
    public static final int YEAR = 5;
    public static final int BITRATE = 6;
    public final static String[] columnNames = {
        getHeader(LABEL_KEY.HEADER_ARTIST),
        getHeader(LABEL_KEY.HEADER_ALBUM),
        getHeader(LABEL_KEY.HEADER_TITLE),
        getHeader(LABEL_KEY.HEADER_LENGTH),
        getHeader(LABEL_KEY.HEADER_TRACK),
        getHeader(LABEL_KEY.HEADER_YEAR),
        getHeader(LABEL_KEY.HEADER_BITRATE)
    };

    public GenreTableModel(SlimGenre genre) throws SlimException {
        super(JukeboxProperties.getInstance().getDatabase().listSongsForGenre(genre));
    }

    @Override
    public int getRowCount() {
        return (dataList.size());
    }

    @Override
    public Object getValueAt(int row, int col) {
        SlimSong song = dataList.get(row);
        switch (col) {
            case (ARTIST):
                return getArtistTitle(song);
            case (ALBUM):
                return getAlbumTitle(song);
            case (TITLE):
                return getSongTitle(song);
            case (LENGTH):
                return song.getLength();
            case (TRACK):
                return song.getTrack();
            case (YEAR):
                return song.getYear();
            case (BITRATE):
                return (song.getBitrate());
            default:
                return (null);
        }
    }

    @Override
    public Class getColumnClass(int column) {
        if (column == TRACK) {
            return Integer.class;
        } else {
            return super.getColumnClass(column);
        }
    }

    @Override
    public int getColumnCount() {
        return (columnNames.length);
    }

    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }

    @Override
    public int getArtistColumnIndex() {
        return ARTIST;
    }

    @Override
    public int getAlbumColumnIndex() {
        return ALBUM;
    }

    @Override
    public int getTitleColumnIndex() {
        return (TITLE);
    }

    @Override
    public int getLengthColumnIndex() {
        return (LENGTH);
    }

    @Override
    public int getTrackColumnIndex() {
        return (TRACK);
    }

    @Override
    public int getYearColumnIndex() {
        return (YEAR);
    }

    @Override
    public int getBitrateColumnIndex() {
        return (BITRATE);
    }

    @Override
    public int getSortColumn() {
        return getTrackColumnIndex();
    }
}
